﻿using System;

namespace TLang.Ast
{
    using Values;

    public class FloatNum : Node
    {
        public String content;
        public double value;


        public FloatNum(String content, String file, int start, int end, int line, int col) : base(file, start, end, line, col)
        {
            this.content = content;
            this.value = Double.Parse(content);

        }


        public static FloatNum parse(String content, String file, int start, int end, int line, int col)
        {
            try
            {
                return new FloatNum(content, file, start, end, line, col);
            }
            catch (FormatException e)
            {
                return null;
            }
        }


        public override Value Interp(Scope s)
        {
            return new FloatValue(value);
        }

        public override Value Typecheck(Scope s)
        {
            return null;
        }

        public override String ToString()
        {
            return value.ToString();
        }
    }
}
